<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>生成题目</title>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <script src="https://cdn.tailwindcss.com"></script>
    <script>
        tailwind.config = {
            theme: {
                extend: {
                    colors: {
                        primary: '#2196F3',        // 主色调：天蓝色
                        'primary-light': '#64B5F6', // 浅色调
                        'primary-dark': '#1976D2',  // 深色调
                        secondary: '#4CAF50',       // 辅助色：清新绿
                        accent: '#FF9800',          // 强调色：温暖橙
                        neutral: '#9E9E9E'          // 中性色
                    }
                }
            }
        }
    </script>
    <style>
        body {
            background: #F5F7FA;
        }
        .safe-bottom {
            padding-bottom: calc(env(safe-area-inset-bottom) + 80px);
        }
        /* 添加微妙的渐变效果 */
        .input-bg {
            background: linear-gradient(to right, #F8FAFF, #F5F7FA);
        }
        .btn-gradient {
            background: linear-gradient(to right, #2196F3, #1E88E5);
        }
    </style>
</head>
<body>
    <div class="w-[375px] mx-auto min-h-screen bg-white relative">
        <!-- 顶部导航 -->
        <header class="fixed top-0 w-[375px] z-50 bg-white border-b border-gray-100">
            <div class="h-[48px] px-4 flex items-center justify-between">
                <h1 class="text-lg font-medium text-gray-800">生成题目</h1>
                <button class="text-sm text-primary">
                    <i class="fas fa-question-circle"></i>
                    帮助
                </button>
            </div>
        </header>

        <!-- 主内容区 -->
        <main class="pt-[48px] px-4 safe-bottom">
            <!-- 输入方式选择 -->
            <section class="mt-4">
                <div class="flex justify-between items-center mb-3">
                    <h2 class="text-base font-medium text-gray-800">选择输入方式</h2>
                </div>
                <div class="grid grid-cols-3 gap-3">
                    <button class="h-[88px] bg-primary/5 rounded-xl flex flex-col items-center justify-center group hover:bg-primary/10 transition-all">
                        <i class="fas fa-keyboard text-xl text-primary mb-2"></i>
                        <span class="text-sm text-gray-700">手动输入</span>
                        <span class="text-xs text-gray-400 mt-1">限6个汉字</span>
                    </button>
                    <button class="h-[88px] bg-primary/5 rounded-xl flex flex-col items-center justify-center group hover:bg-primary/10 transition-all">
                        <i class="fas fa-list-ol text-xl text-primary mb-2"></i>
                        <span class="text-sm text-gray-700">单元选择</span>
                        <span class="text-xs text-gray-400 mt-1">1-60单元</span>
                    </button>
                    <button class="h-[88px] bg-primary/5 rounded-xl flex flex-col items-center justify-center group hover:bg-primary/10 transition-all">
                        <i class="fas fa-camera text-xl text-primary mb-2"></i>
                        <span class="text-sm text-gray-700">拍照识别</span>
                        <span class="text-xs text-gray-400 mt-1">自动识别</span>
                    </button>
                </div>
            </section>

            <!-- 拍照预览区域 -->
            <section class="mt-6">
                <div class="flex justify-between items-center mb-3">
                    <h2 class="text-base font-medium text-gray-800">拍照识别</h2>
                    <button class="text-xs text-primary">重新拍照</button>
                </div>
                <!-- 图片预览区域 -->
                <div class="relative aspect-[4/3] rounded-xl overflow-hidden">
                    <!-- 未拍照状态 -->
                    <div class="absolute inset-0 bg-gray-50 flex flex-col items-center justify-center" id="placeholder">
                        <i class="fas fa-camera text-4xl text-gray-300 mb-2"></i>
                        <p class="text-sm text-gray-400">点击拍照识别汉字</p>
                    </div>
                    
                    <!-- 拍照预览 -->
                    <img src="" alt="拍照预览" class="w-full h-full object-cover hidden" id="preview">
                    
                    <!-- 拍照按钮 -->
                    <input type="file" accept="image/*" capture="camera" class="hidden" id="camera">
                    <button onclick="document.getElementById('camera').click()" 
                            class="absolute inset-0 w-full h-full cursor-pointer">
                    </button>
                    
                    <!-- 加载状态 -->
                    <div class="absolute inset-0 bg-black/50 items-center justify-center hidden" id="loading">
                        <div class="text-white flex flex-col items-center">
                            <i class="fas fa-spinner fa-spin text-2xl mb-2"></i>
                            <span class="text-sm">正在识别...</span>
                        </div>
                    </div>
                </div>
            </section>

            <!-- 难度选择 -->
            <section class="mt-8">
                <h2 class="text-base font-medium text-gray-800 mb-3">难度选择</h2>
                <div class="grid grid-cols-3 gap-3">
                    <button class="h-[44px] btn-gradient text-white rounded-xl shadow-sm">容易</button>
                    <button class="h-[44px] bg-gray-50 text-gray-600 rounded-xl hover:bg-gray-100 transition-all">中等</button>
                    <button class="h-[44px] bg-gray-50 text-gray-600 rounded-xl hover:bg-gray-100 transition-all">较难</button>
                </div>
            </section>

            <!-- 语言风格 -->
            <section class="mt-6">
                <h2 class="text-base font-medium text-gray-800 mb-3">语言风格</h2>
                <div class="grid grid-cols-3 gap-3">
                    <button class="h-[44px] btn-gradient text-white rounded-xl shadow-sm">标准</button>
                    <button class="h-[44px] bg-gray-50 text-gray-600 rounded-xl hover:bg-gray-100 transition-all">趣味</button>
                    <button class="h-[44px] bg-gray-50 text-gray-600 rounded-xl hover:bg-gray-100 transition-all">文学</button>
                </div>
            </section>
        </main>

        <!-- 底部导航栏 -->
        <nav class="fixed bottom-0 w-[375px] bg-white border-t border-gray-100">
            <div class="grid grid-cols-5 h-[56px]">
                <a href="generate.html" class="flex flex-col items-center justify-center">
                    <i class="fas fa-plus-circle text-primary"></i>
                    <span class="text-xs mt-1 text-primary">生成</span>
                </a>
                <a href="study.html" class="flex flex-col items-center justify-center">
                    <i class="fas fa-book text-gray-400"></i>
                    <span class="text-xs mt-1 text-gray-400">学习</span>
                </a>
                <a href="history.html" class="flex flex-col items-center justify-center">
                    <i class="fas fa-history text-gray-400"></i>
                    <span class="text-xs mt-1 text-gray-400">历史</span>
                </a>
                <a href="rewards.html" class="flex flex-col items-center justify-center">
                    <i class="fas fa-gift text-gray-400"></i>
                    <span class="text-xs mt-1 text-gray-400">奖励</span>
                </a>
                <a href="profile.html" class="flex flex-col items-center justify-center">
                    <i class="fas fa-user text-gray-400"></i>
                    <span class="text-xs mt-1 text-gray-400">我的</span>
                </a>
            </div>
            <!-- 底部安全区域适配 -->
            <div class="h-[env(safe-area-inset-bottom)]"></div>
        </nav>

        <!-- 生成按钮 -->
        <div class="fixed bottom-[56px] left-0 w-[375px] bg-white border-t border-gray-100 px-4 py-3">
            <button class="w-full h-[48px] btn-gradient text-white rounded-xl flex items-center justify-center text-base font-medium shadow-sm hover:opacity-95 transition-all">
                开始生成
            </button>
        </div>

        <!-- 拍照识别弹窗 -->
        <div class="fixed inset-0 bg-black/50 hidden items-center justify-center">
            <div class="w-[320px] bg-white rounded-xl p-4">
                <div class="aspect-[4/3] bg-gray-50 rounded-xl mb-4 flex items-center justify-center">
                    <i class="fas fa-camera text-4xl text-gray-300"></i>
                </div>
                <div class="flex gap-3">
                    <button class="flex-1 h-[44px] bg-gray-50 text-gray-600 rounded-xl hover:bg-gray-100 transition-all">取消</button>
                    <button class="flex-1 h-[44px] btn-gradient text-white rounded-xl shadow-sm hover:opacity-95 transition-all">拍照</button>
                </div>
            </div>
        </div>
    </div>

    <!-- 添加必要的JavaScript -->
    <script>
        document.getElementById('camera').addEventListener('change', function(e) {
            const file = e.target.files[0];
            if (file) {
                // 显示预览
                const reader = new FileReader();
                reader.onload = function(e) {
                    const preview = document.getElementById('preview');
                    preview.src = e.target.result;
                    preview.classList.remove('hidden');
                    document.getElementById('placeholder').classList.add('hidden');
                }
                reader.readAsDataURL(file);
                
                // 这里可以添加上传和识别的逻辑
                // document.getElementById('loading').classList.remove('hidden');
                // 调用识别API...
            }
        });
    </script>
</body>
</html>